import java.util.Scanner;
import java.util.Arrays;
public class Massive {
    public static void first(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] test = new int[sc.nextInt()];
        sc.close();
        for (int i = 0; i < test.length; i++) {
            test[i] = i+1;
        }
        for (int i: test) {
            System.out.print(i + " ");
        }
    }

    public static void finishElement(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] numbers = new int[length];
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = sc.nextInt();
        }
        System.out.println(numbers[length-1]);
    }

    public static void selectedElement(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] numbers = new int[length];
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = sc.nextInt();
        }
        System.out.println(numbers[sc.nextInt()-1]);
    }

    public static void evenNumbersInArray(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt(), summ=0;
        int[] numbers = new int[length/2];
        for (int i = 2, j=0; i<=length && j <= length /2; i++){
            if (i%2==0) {
                numbers[j] = i;
                summ += i;
                j++;
                if (j!=length/2) System.out.print(i + " ");

            }
        }
        System.out.println(numbers[length/2 - 1] + "\n"+ summ);

    }

    public static void printNumGreaterPrevious(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] nums = new int[length];
        for (int i = 0; i < length; i++) {
            nums[i] = sc.nextInt();
            if (i > 0 && nums[i] > nums[i-1]) {
                System.out.print(nums[i] + " ");
            }
        }
    }

    public static void methodSplit(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        for (String i: str.split(",")){
            System.out.println(i);
        }
    }

    public static void printNumberFromArray(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[sc.nextInt()];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        int number = sc.nextInt();
        Arrays.sort(arr);
        System.out.println(number <= arr.length && number > 0 ? arr[number-1]: number == 0 ? arr[0] : "Ошибка ввода");
    }

    public static void createdArraysAndPrintSortedString(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] arr = str.split(" ");;
        int[] numbers = new int[str.split(" ").length];

        for (int i = 0; i< str.split(" ").length; i++){
            numbers[i] = Integer.parseInt(arr[i]);
        }
        Arrays.sort(numbers);
        System.out.println(Arrays.toString(numbers));
    }

    public static void swapNumbersAndOut(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] arr = sc.nextLine().split(" ");
        String temp;

        for (int i = 1; i < arr.length - 2; i+=2) {
                temp = arr[i];
                arr[i] = arr[i + 1];
                arr[i+1] = temp;
        }
        for (String newArrays: arr) {
            System.out.print(newArrays+" ");
        }
    }

    public static void minLengthSymbolInString(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] arr = sc.nextLine().split(" ");
        String min = "";
        int minIndex=0;

        for (int i = 0; i< arr.length; i++){
            if (i == 0) min = arr[0];
            if (arr[i].length() < min.length()){
                min = arr[i];
                minIndex = i;
                if (min.length() == 1) break;
            }

        }
        System.out.println(minIndex+1);
    }

    public static void minSumAcross2Indices(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] array = sc.nextLine().split(" ");
        int[] arrayNum = new int[array.length];
        int min=0;

        for (int i = 0; i < array.length; i++) {
            arrayNum[i] = Integer.parseInt(array[i]);
        }

        for (int i = 0, j = 0; i < arrayNum.length - 2; i++) {
            int sum = arrayNum[i]+arrayNum[i+2];
            if (i == 0) min = sum;
            if (sum < min) min = sum;
        }
        System.out.printf(min == 0 ? "" + 0 : "" + min);
    }

    public static void tableMultiplication(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[][] nm = new int[n][m];

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                nm[i-1][j-1] = i * j;
                System.out.print(nm[i-1][j-1] + (j < m ? " " : "\n"));
            }
        }
    }

    public static void addedStringInMultidimensionalArray(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[][] nm = new String[sc.nextInt()][];
        sc.nextLine(); // необходима для считывания строки str

        for (int i = 0; i < nm.length; i++){
            String str = sc.nextLine();
            nm[i] = str.split(" ");
            System.out.println(Arrays.toString(nm[i]));
        }

    }

    public static void readAndOutMatrix(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = 0, n = 0;

        while (sc.hasNext()) {
            String str = sc.nextLine();
            String[] array = str.split(" ");
            if (n == 0) n = array.length;
            m++;
        }
        System.out.println("Строк: " + m);
        System.out.println("Столбцов: " + n);

    }

    public static void diagonalArrays(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = 0, n = 0;
        String str = "";

        while (sc.hasNext()) {
            String s = sc.nextLine();
            if (n == 0) n = s.split(" ").length;
            str += s;
            m++;
        }

        String[] array = new String[m];
        array = str.split(" ", 3);
        String[][] arrayMulti = new String[m][n];

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                arrayMulti[i][j] = array[(n-1)*i +j];
                if (i == j)  System.out.print(arrayMulti[i][j]);
            }
        }



    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = 0, n = 0;
        String str = "";

        while (sc.hasNext()) {
            String s = sc.nextLine();
            if (n == 0)
                n = s.split(" ").length;
            str += s + " ";
            m++;
        }
        String[] array = new String[m];
        array = str.split(" ");
        String[][] arrayMulti = new String[m][n];

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                arrayMulti[i][j] = array[n*i +j];

            }
        }

        String[][] arrayMulti90Right = new String[n][m];
        for (int i = 0; i < n; i ++) {
            for (int j = m - 1 ; j >= 0; j--){
                arrayMulti90Right[i][j] = arrayMulti[j][i];
                System.out.print(j > 0 ? arrayMulti90Right[i][j]+ " ":arrayMulti90Right[i][j]+ "\n");
            }
        }



    }





}


